package com.chaintor.demo.math;

import org.apache.commons.math3.analysis.UnivariateFunction;

public class BspIntegralFunc implements UnivariateFunction {
    private BspBaseFunc baseFunc;
    private double _L,_S,_U;

    private int _k1,_k2;

    private double lambda(double d){
        return  Math.exp(_L-(_L-_S)*Math.exp(-d/_U));
    }

    /**
     * 构造函数
     * @param k1
     * @param k2
     * @param bspBase
     */
    public BspIntegralFunc(int k1,int k2,BspBaseFunc bspBase,double L,double S,double U){
        _k1 = k1;
        _k2 = k2;
        _L = L;
        _S = S;
        _U = U;
        baseFunc = bspBase;
    }

    /**
     * 惩罚矩阵积分俺叔
     * @param x
     * @return
     */
    public double value(double x) {
        return baseFunc.f4Derivative(_k1,x)*baseFunc.f4Derivative(_k2,x)*lambda(x);
    }


}
